home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / language / embedded / develop / libsrc11.arc / STARTUP.S < prev    next >
Text File  |  1989-04-27  |  2KB  |  78 lines

  1. ******************************************************************************
  2. * startup.s 3.3 1/2/86 
  3. *
  4. *        68HC11 CROSS C COMPILER RUN-TIME LIBRARY
  5. *
  6. *           (c) Copyright 1984, Motorola, Inc.
  7. *
  8. *  FUNCTION NAME:    .startup
  9. *
  10. *  ACTION:        Do the initialization of global and static variables.
  11. *            Set the stack pointer to the value defined in the
  12. *            68HC11 linkmap.
  13. *            When control is returned from MAIN then a BRA * 
  14. *            instruction is invoked.
  15. *
  16. *  REGISTERS AND STACK:
  17. *
  18. *  ON ENTRY:        No guaranteed values
  19. *
  20. *            SP:     Undefined
  21. *
  22. *            This routine assumes that the linkmap has the following
  23. *            symbols defined l__PSINS, l__PSINE, and l__DSINS.
  24. *            They are assumed to be defined around ipsct 
  25. *            in the following way:
  26. *
  27. *                l__PSINS = .;
  28. *                ipsct : {}
  29. *                l__PSINE = .-1;
  30. *            
  31. *            and after idsct as follows:
  32. *
  33. *                idsct : {}
  34. *                l__DSINE = .-1;
  35. *
  36. *
  37. *  ON CALL TO MAIN:    
  38. *        X:    Undefined
  39. *
  40. *        STACK:    
  41. *            Return Address 
  42. *
  43. *        SP:    The location defined by l__STKHI in the linkmap
  44. *
  45. *         IDSCT:    All global and static variables initialized.
  46. *
  47. *
  48. ******************************************************************************
  49.     xref    l__DSINE
  50.     xref    l__PSINS
  51.     xref    l__PSINE
  52.     xref    ..stret
  53.  
  54.     dsct
  55.     xdef    .stretp
  56. .stretp:
  57.     rmb    2
  58.  
  59.     psct
  60.     xdef    .startup
  61. .startup:
  62.     lds    #l__DSINE    Load end addr of the initialized data area
  63.     ldx    #l__PSINE    Load end addr of the initialization constants
  64. loop:    cpx    #l__PSINS    Compare to base addr of init constants
  65.     blo    initdone
  66.     ldaa    0,%x        load the init constant
  67.     psha            store into the data area (idsct)
  68.     dex            decrement the base pointer
  69.     bra    loop
  70. initdone:
  71.     lds    #l__STKHI    Load the stack pointer with the start of stack
  72.     ldd    #..stret    Initialize structure return area pointer
  73.     std    .stretp
  74.     jsr    main        Jump to the user program
  75. here:
  76.     bra    here        Cease processing, go into an infinite loop
  77.     end
  78.